import React,{
  PropTypes
} from 'react'
import {
  Text,
  StyleSheet,
} from 'react-native'
import { SpecialCharacter } from '../config'
const styles = StyleSheet.create({

})
const reg = new RegExp(`@(.*?)${SpecialCharacter}`,'g')
//"@BZ @C\nZ".match(r)
//["@BZ"]
const CommentText = ({txt, }) => {
  const children = []
  txt.replace(reg,(matchTxt,name,index) => {
    children.push({
      name,
      index,
      length:matchTxt.length,
    })
  })
  children.map(({name,index,length})=>{

    React.createElement(Text,{},txt.substr(index,length))
  })
  if(children.length){
    React.createElement(Text,{},)
  }else{
    return <Text>{txt}</Text>
  }
  return (
    <Text></Text>
  )
}
CommentText.propTypes = {
  txt: PropTypes.string.required,
  onPress: PropTypes.func,
}

export default CommentText
